# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=maven
pkgver=3.9.9
_pkgname="$pkgname-${pkgver%%.*}"
pkgrel=0
pkgdesc="Java project management and project comprehension tool"
url="https://maven.apache.org/"
# riscv64: blocked by openjdk8
arch="noarch !riscv64"
license="Apache-2.0"
options="!check" # repackaged release without a test suite
depends="java-jdk"
makedepends="openjdk8" # for build order resolution
source="https://archive.apache.org/dist/maven/$_pkgname/$pkgver/binaries/apache-maven-$pkgver-bin.tar.gz"
builddir="$srcdir/apache-$pkgname-$pkgver"

package() {
	local m2_home="/usr/share/java/$_pkgname"
	local destdir="${pkgdir}$m2_home"

	local dir; for dir in bin boot lib; do
		mkdir -p "$destdir/$dir"
	done

	install -m644 -Dt "$destdir"/bin ./bin/*.conf
	install -m644 -Dt "$destdir"/boot ./boot/*.jar
	install -m644 -Dt "$destdir"/lib ./lib/*.jar
	cp -Rp ./conf "$destdir"/

	mkdir -p "$pkgdir"/usr/bin

	local file; for file in mvn mvnDebug mvnyjp; do
		install -m755 -Dt "$destdir"/bin ./bin/$file
		ln -sf "$m2_home"/bin/$file "$pkgdir"/usr/bin/$file
	done

	mkdir "$pkgdir"/etc
	cat > "$pkgdir"/etc/mavenrc <<-EOF
		M2_HOME="$m2_home"
	EOF
}

sha512sums="
a555254d6b53d267965a3404ecb14e53c3827c09c3b94b5678835887ab404556bfaf78dcfe03ba76fa2508649dca8531c74bca4d5846513522404d48e8c4ac8b  apache-maven-3.9.9-bin.tar.gz
"
